<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="shortcut icon" href="favicon.ico"> <link href="__CSS__/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="__CSS__/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="__CSS__/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="__CSS__/animate.min.css" rel="stylesheet">
<link href="__CSS__/style.min862f.css?v=4.1.0" rel="stylesheet">
<link href="__CSS__/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<link href="__CSS__/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<body>

<!-- Panel Style -->
<div class="ibox float-e-margins">
    <span><br>&nbsp;&nbsp;&nbsp;</span>
    <i class="fa fa-home"></i> <a target="_top" href="{:U('/Admin/index')}">首页</a> &raquo; 文章管理 &raquo; 文章列表
    <div class="ibox-title">
        <h5>文章管理</h5>
        <div class="ibox-tools">
            <a class="collapse-link">
                <i class="fa fa-chevron-up"></i>
            </a>
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                <i class="fa fa-wrench"></i>
            </a>
            <ul class="dropdown-menu dropdown-user">
                <li><a href="#">选项1</a>
                </li>
                <li><a href="#">选项2</a>
                </li>
            </ul>
            <a class="close-link">
                <i class="fa fa-times"></i>
            </a>
        </div>
    </div>
    <div class="ibox-content">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <div class="row row-lg">
            <div class="col-sm-12">
                <!-- Example Pagination -->
                <!--编辑-删除按钮-->
                <div id="toolbar" class="btn-group" id="art-opt">
                    <button id="btn_add" type="button" class="btn btn-success btn-xl btn-outline" onclick="artOpt.add()">
                        <span class="glyphicon glyphicon-plus" id="add" aria-hidden="true"></span>新增
                    </button>
                    <button id="btn_edit" type="button" class="btn btn-info btn-xl btn-outline" onclick="artOpt.edit()">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>编辑
                    </button>
                    <button id="btn_remove" type="button" class="btn btn-warning btn-xl btn-outline" onclick="artOpt.remove()">
                        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
                    </button>
                </div>
                <div class="example-wrap">
                    <div class="example">
                        <table id="art">
                        </table>
                    </div>
                </div>
                <!-- End Example Pagination -->
            </div>
        </div>
    </div>
</div>
<!-- End Panel Style -->



<script src="__JS__/jquery.min.js?v=2.1.4"></script>
<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
<script src="__JS__/content.min.js?v=1.0.0"></script>
<script src="__JS__/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="__JS__/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="__JS__/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__JS__/plugins/layer/layer.min.js"></script>
<script src="__JS__/demo/bootstrap-table-demo.min.js"></script>

<script>

        var artOpt,
            btnAdd =  $('#btn_add'),
            art =  $('#art');
            artOpt = {
                add: function () {
                    //弹出一个iframe层
                 /*   $('#parentIframe').on('click', function(){
                        layer.open({
                            type: 2,
                            title: 'iframe父子操作',
                            maxmin: true,
                            shadeClose: true, //点击遮罩关闭层
                            area : ['800px' , '520px'],
                            content: 'test/iframe.html'
                        });
                    });*/



                },
                edit: function () {

                },
                remove:function () {
                    var rows = art.bootstrapTable('getSelections');
                    var ids = [];
                    if (rows.length > 0) {
                    for(var i=0; i<rows.length; i++){
                        ids.push(rows[i]['art_id']);
                    }
                    swal({
                        title: "你确认要删除"+rows.length+"记录吗?",
                        text: "删除后将无法恢复，请谨慎操作！",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "delete",
                        closeOnConfirm: false
                    },
                    function(){
                        swal("删除成功!", rows.length+"条记录已经删除！", "success");

                            $.ajax({
                                url: "{:U('/Admin/Article/remove')}",
                                type: 'POST',
                                data: {
                                    'ids' : ids.join(','),
                                },
                                success: function (data) {
                                    if (data) {
                                        art.bootstrapTable('refresh');
                                    } else {
                                        $.messager.alert('删除提示','没有任何数据被删除','warning');
                                    }


                                }
                            });

                    });
                    } else {
                        swal('删除提示','删除记录至少选择一条数据');
                    }
                }
            }
        art.bootstrapTable({
            url: "{:U('/Admin/Article/artData')}",
            columns:[{
                'field': 'id',
                'title': '编号',
                'checkbox':true,

            } ,{
                'field': 'art_title',
                'title': '标题'
            },{
                'field': 'art_author',
                'title': '作者'
            },{
                'field': 'art_view',
                'title': '点击数'
            },{
                'field': 'pub_time',
                'title': '发表时间',
                sortable:true,
            },
            {
                'field': 'art_id',
                'title': '文章编号',
                'visible': false,
            }
            ],
            toolbar: '#toolbar',
            pagination: true, //是否显示分页（*）
            ///queryParams: oTableInit.queryParams,//传递参数（*）
            sidePagination: "client", //分页方式：client客户端分页，server服务端分页（*）
            pageNumber:1, //初始化加载第一页，默认第一页
            pageSize: 50, //每页的记录行数（*）
            pageList: [10, 20, 30, 40], //可供选择的每页的行数（*）
            showColumns:true,
            showToggle:true,
            showRefresh:true,
            search:true,
            keyEvents:true,




    })
</script>


</body>
</html>